home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2003 #8 / K-CD-8-2003.ISO / Eraser / EraserSetup.exe / {app} / Examples / VB / Form1.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  2001-08-24  |  3.1 KB  |  99 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Eraser Sample in VB"
  4.    ClientHeight    =   1410
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4770
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1410
  10.    ScaleWidth      =   4770
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Erase 
  13.       Caption         =   "&Erase"
  14.       Height          =   375
  15.       Left            =   3720
  16.       TabIndex        =   2
  17.       Top             =   960
  18.       Width           =   975
  19.    End
  20.    Begin VB.TextBox FileName 
  21.       Height          =   375
  22.       Left            =   120
  23.       TabIndex        =   1
  24.       Top             =   960
  25.       Width           =   3495
  26.    End
  27.    Begin VB.Label Label 
  28.       Caption         =   "Enter file to erase"
  29.       Height          =   735
  30.       Left            =   120
  31.       TabIndex        =   0
  32.       Top             =   120
  33.       Width           =   4575
  34.    End
  35. Attribute VB_Name = "Form1"
  36. Attribute VB_GlobalNameSpace = False
  37. Attribute VB_Creatable = False
  38. Attribute VB_PredeclaredId = True
  39. Attribute VB_Exposed = False
  40. Private Sub Erase_Click()
  41.     ' variables
  42.     Dim Result As Long
  43.     Dim Bytes(2) As Long
  44.     Dim Context As Long
  45.     Context = 0
  46.     ' initialize library
  47.     Result = eraserInit()
  48.     If eraserError(Result) Then
  49.         Label.Caption = "Error: eraserInit returned " & Result
  50.         GoTo Error
  51.     End If
  52.     ' create context
  53.     Result = eraserCreateContext(Context)
  54.     If eraserError(Result) Then
  55.         Label.Caption = "Error: eraserCreateContext returned " & Result
  56.         GoTo Error
  57.     End If
  58.     ' set data type
  59.     Result = eraserSetDataType(Context, ERASER_DATA_FILES)
  60.     If eraserError(Result) Then
  61.         Label.Caption = "Error: eraserSetDataType returned " & Result
  62.         GoTo Error
  63.     End If
  64.     ' add files to erase
  65.     Result = eraserAddItem(Context, FileName.Text, Len(FileName.Text))
  66.     If eraserError(Result) Then
  67.         Label.Caption = "Error: eraserAddItem returned " & Result
  68.         GoTo Error
  69.     End If
  70.     ' erase
  71.     Result = eraserStartSync(Context)
  72.     If eraserError(Result) Then
  73.         Label.Caption = "Error: eraserStartSync returned " & Result
  74.         GoTo Error
  75.     End If
  76.     ' done erasing, query some statistics
  77.     Label.Caption = "File erased."
  78.     ' the second parameter is a 64-bit value, thus passing array ByRef
  79.     Result = eraserStatGetArea(Context, Bytes(1))
  80.     If eraserOK(Result) Then
  81.         Label.Caption = Label.Caption & " (" & Bytes(1) & " bytes)"
  82.     End If
  83.              
  84.     ' and clean up
  85.     GoTo CleanUp
  86. Error:
  87.     ' handle error
  88. CleanUp:
  89.     ' show Erasing Report
  90.     Result = eraserShowReport(Context, Form1.Hwnd)
  91.     If eraserError(Result) Then
  92.         Label.Caption = Label.Caption & " Oops, eraserShowReport returned " & Result
  93.     End If
  94.     ' destroy context
  95.     Result = eraserDestroyContext(Context)
  96.     ' clean up library
  97.     Result = eraserEnd()
  98. End Sub
  99.